package com.classloader;

/**
 * @author: csh
 * @Date: 2021/12/24 07:26
 * @Description:
 */
public class ClassLoaderTest1 {
    public static void main(String[] args) {
        ClassLoader classLoader = ClassLoader.getSystemClassLoader();
        //sun.misc.Launcher$AppClassLoader@18b4aac2
        System.out.println(classLoader);
        ClassLoader extClassLoader = classLoader.getParent();
        System.out.println(extClassLoader);
        //试图获取引导类加载器
        ClassLoader bootstrapClassLoader = extClassLoader.getParent();
        System.out.println(bootstrapClassLoader);

        try {
            ClassLoader classLoader1 = Class.forName("java.lang.String").getClassLoader();
            System.out.println(classLoader1);
            //自定义类加载器
            ClassLoader classLoader2 = Class.forName("com.classloader.User").getClassLoader();
            System.out.println(classLoader2);

            //关于数组类型的加载
            String[] arrStr = new String[10];
            System.out.println(arrStr.getClass().getClassLoader());
        }catch (Exception e){

        }


    }
}
